// 	ID : pallab81
// 	PROG : 10482
// 	LANG : C++
// 	2011-08-16-09.58.07 Tuesday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define fo(i,ed) for(int i = 0 ; i < ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

inline void wait( double seconds ){
    double endtime = clock() + ( seconds+ CLOCKS_PER_SEC );
    while( clock() < endtime ){;}
}
int n;
int w[ 33 ];
int k;
int cando[ 33 ][ 641 ][ 641 ];

inline void Read(){
    CI(n);
    fo(i,n){
        CI(w[i]);
    }
}
inline int MAX(int a, int b, int c){
    return max(a, max(b,c) );
}
inline int MIN(int a, int b, int c){
    return min(a, min(b,c) );
}
inline int go(int id, int a, int b, int c){
    if( id==n ){
        return MAX(a,b,c) - MIN(a,b,c);
    }

    int &best = cando[ id ][ a ][ b ];
    if( best!=-1 ){
        return best;
    }
    int _1 = go(id+1, a+w[id], b, c);
    int _2 = go(id+1, a, b+w[id], c);
    int _3 = go(id+1, a, b, c+w[id] );

    best = MIN(_1,_2,_3);
return best;
}

inline void Proc(){
    SET( cando , -1);
    printf("Case %d: %d\n",k,go(0,0,0,0));
}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("in.txt","rt",stdin);
    #endif
    int cases;
    k=1;
    for( CI(cases) ; cases ; --cases,++k ){
        Read();
        Proc();
    }
return 0;
}
